<template>
  <view class="normal-login-container">

    <view class="item-wrap" style="margin-bottom: 0">
      <view class="lineBottom10">
        <uni-section title="订单信息" type="line"/>
      </view>

      <view style="margin: 8rpx 20rpx 8rpx 20rpx">
        <uni-forms labelWidth="auto">
			<uni-forms-item label="合同编号:">
			  <text  >{{ isNoEmpty(ruleForm.orderInfoVo.contractNo) }}</text>
			</uni-forms-item>
			  <uni-forms-item label="订单编号:">
				<text >{{ isNoEmpty(ruleForm.orderInfoVo.orderNo)  }}</text>
			  </uni-forms-item>

			  <uni-forms-item label="年行驶公里数:">
				<text >{{ isNoEmpty(ruleForm.orderInfoVo.maintenanceAnnualMileageVal)  }}</text>
			  </uni-forms-item>

			  <uni-forms-item label="月维保费:">
				<text >{{ isNoEmpty(ruleForm.orderInfoVo.maintenanceMonthlyPrice)  }}</text>
			  </uni-forms-item>

			  <uni-forms-item label="付款频次:">
				<text >{{ isNoEmpty(ruleForm.orderInfoVo.payFrequency) }}</text>
			  </uni-forms-item>

			  <uni-forms-item label="支付时间:">
				  <text v-if="ruleForm.orderInfoVo.paymentDate=='1'">先付</text>
				  <text v-if="ruleForm.orderInfoVo.paymentDate=='2'">后付</text>
				
			  </uni-forms-item>

			  <uni-forms-item label="是否包含替车:">
				<text v-if='ruleForm.orderInfoVo.isReplacementCar==0'>否</text>
				<text v-if='ruleForm.orderInfoVo.isReplacementCar==1'>是</text>
			  </uni-forms-item>
			  <uni-forms-item label="是否含司机:">
					<text v-if='ruleForm.orderInfoVo.isBringDriver==0'>否</text>
					<text v-if='ruleForm.orderInfoVo.isBringDriver==1'>是</text>
			  </uni-forms-item>
			  <uni-forms-item label="合同保证金:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.margin) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="首期租金:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.firstPayMoney) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="残值金额:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.endPayMoney) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="其他加装费:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.retrofittingFee) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="GPS费用:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.gpsAmount) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="购置税:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.purchaseTaxPrice) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="上牌费:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.registerPrice) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="物流费:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.logisticFee) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="每期租金:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.planRent) }}</text>
			  </uni-forms-item>
			  <uni-forms-item label="租期:">
			  				<text >{{ isNoEmpty(ruleForm.orderInfoVo.leaseTerm) }}</text>
			  </uni-forms-item>
        </uni-forms>
      </view>
    </view>
  </view>
</template>

<script>
	import constant from "../../../utils/constant";
import {
	  getQuotaProductByOrderCar
	} from "@/api/storage/in.js";
export default {
  name: 'customerOrderInfo',//基础信息
  dicts: ['customer_type', 'car_business_type'],
  props: {
   value: {
     type: Object,
     default: {}
   }
  },
 computed: {
   ruleForm: {
     get() {
       let that = this
       const proxy = new Proxy(that.value, {
         get(target, key) {
           return Reflect.get(target, key)
         },
         set(target, key, value) {
           that.$emit('input', {...target, [key]: value})
           return true
         }
       })
       return proxy
     }
   },
 },
  data() {
    return {};
  },
  watch:{
	 'ruleForm.orderInfoVo':{
		 deep:true,
		 handler(val){
			 this.ruleForm.orderInfoVo = val
			 console.log(val,'hishihsdifhi')
		 },
		 immediate:true
	 }
  },
  created() {
		console.log(this.ruleForm,'ruleForm')
  },
  mounted() {
	  this.detailInfo()
  },
  methods: {
	    detailInfo(){
	          var _this = this;
	          if (this.ruleForm != null && this.ruleForm.carInStorage != null) {
	            this.getQuota(this.ruleForm.orderInfoVo.orderNo, this.ruleForm.carBasicVo.modelName);
	          } else {
	            setTimeout(function () {
	              _this.detailInfo();
	            }, 100)
	          }
	        },
	        getQuota(orderCode, carModelName){
				
	          if (this.Empty(orderCode)) return;
	          if (this.Empty(carModelName)) return;
	          getQuotaProductByOrderCar(orderCode, carModelName).then(res => {
				  console.log(res,'123123231')
	            var pd = res.data;
	            if (!pd) {
	              pd = {};
	            }
	            if (!pd['plan']) {
	              pd['plan'] = {};
	            }
					
				this.quotaProduct = pd;
				console.log(pd.plan,'pd.planpd.plan')
				this.ruleForm.orderInfoVo.gpsAmount = pd.plan.gpsFee;
				this.ruleForm.orderInfoVo.maintenanceMonthlyPrice = pd.maintenancePrice;
				this.ruleForm.orderInfoVo.purchaseTaxPrice = pd.carPurchaseTax;
				this.ruleForm.orderInfoVo.endPayMoney = pd.plan.planResidual;
				this.ruleForm.orderInfoVo.maintenanceAnnualMileageVal = pd.maintenanceAnnualMileageKey;
				this.ruleForm.orderInfoVo.payFrequency = pd.plan.planPaymentFrequencyTypeStr;
				this.ruleForm.orderInfoVo.paymentDate = pd.plan.planPaymentMethodType;
				this.ruleForm.orderInfoVo.margin = pd.plan.planContractCashdeposit;
				this.ruleForm.orderInfoVo.firstPayMoney = pd.plan.planFirstRent;
				this.ruleForm.orderInfoVo.retrofittingFee = Number(pd.otherFeeAmount) + Number(pd.attachedDecorationAmount);
				this.ruleForm.orderInfoVo.registerPrice = pd.carLicensePrice;
				this.ruleForm.orderInfoVo.logisticFee = pd.plan.logisticFee;
				this.ruleForm.orderInfoVo.planRent = pd.plan.planRent;
				this.ruleForm.orderInfoVo.leaseTerm = pd.plan.planTenancyType;
				console.log(this.ruleForm.orderInfoVo,'this.ruleForm.orderInfoVo')
	            
	          }).finally(() => {
	            this.loading = false
	          })
	        },
  },
};
</script>

<style lang="scss" scoped>
.car-wrap {
  display: flex;
  flex-direction: column;
  padding: 20rpx 20rpx 20rpx 0;
  border: 1px solid #dadada;
  margin: 10rpx 20rpx;
  border-radius: 8rpx;

}


</style>


